<?php
/**
 * Created by PhpStorm.
 * User: shaowei
 * Date: 2019/7/19
 * Time: 下午2:05
 */

namespace App\Http\Model;


use Illuminate\Support\Facades\Redis;


class RoomTurntable
{
    private $redisRoom = "ROOM:"; //ROOM:HEART::{room_id}

    /**
     * 设置是否启用-主持
     * @param $room_id
     * @param $state 0.关闭 1.开启
     * @return boolean
     */
    public function setTurntableState($room_id, $state){
        $key = $this->redisRoom . $room_id;
        $ret = Redis::HSET($key, 'turntable', $state);
        return $ret;
    }

    /**
     * 获取聊天屏幕是否启用
     * @param $room_id
     * @return int  0.关闭 1.开启
     */
    public function getTurntableOpened($room_id){
        $key = $this->redisRoom . $room_id;
        $data = Redis::HGET($key, 'turntable');
        if ($data === null){
            return 1;
        }
        return intval($data);
    }

}